package json

import groovy.json.JsonBuilder
import groovy.json.JsonOutput

//创建json
def builder = new JsonBuilder()
builder {
    data {
        name "侯征"
        age 25
        skill "java","python","groovy"
    }
    code 200
}
println(builder.toString())
//按照树形结构输出
println builder.toPrettyString()
//写入文件
new FileWriter("data.json").withWriter {
    it << builder.toPrettyString()
}
